﻿using System;
using System.Collections.Generic;
using HotUpdateMessage;
using UnityEngine;

namespace HotUpdateDLL
{
    /// <summary>
    /// 组件工厂
    /// </summary>
    public class ComponentFactory : Singleton<ComponentFactory>
    {
        public override void Init()
        {
            base.Init();

            #region 监听消息
            // 监听Distrot
            MessageCenter.Instance.AddListener(MessageType.DestrotGameObject, (m) =>
            {
                // 监听逻辑
                GameObject gObj = m.Content as GameObject;
                if (ReferenceLadingManager.Instance.dicScriptRefer.ContainsKey(gObj))
                {
                    // 释放对应的脚本
                    
                    ReferenceLadingManager.Instance.dicScriptRefer[gObj]=null;
                    ReferenceLadingManager.Instance.dicScriptRefer.Remove(gObj);
                }
            });

            #endregion

        }

        public void Update()
        {

        }

        public void Awake()
        {

        }

        public void Start()
        {

        }

        public void FixedUpdate()
        {

        }
        public void LateUpdate()
        {

        }
    }
}
